How can i convert a string into byte[] of unsigned int 32 C#
Posted
by Miroo
on Stack Overflow
See other posts from Stack Overflow
or by Miroo
Published on 2010-05-27T10:11:01Z
Indexed on
2010/05/27
10:21 UTC
Read the original article
Hit count: 230
i have string like "0x5D, 0x50, 0x68, 0xBE, 0xC9, 0xB3, 0x84, 0xFF" i wanna convert it into
byte[] key= new byte[] { 0x5D, 0x50, 0x68, 0xBE, 0xC9, 0xB3, 0x84, 0xFF};
i thought about splitting the string by ',' then loop on it and setvalue into another byte[] in index of i
string Key = "0x5D, 0x50, 0x68, 0xBE, 0xC9, 0xB3, 0x84, 0xFF";
string[] arr = Key.Split(',');
byte[] keybyte= new byte[8];
for (int i = 0; i < arr.Length; i++)
{
keybyte.SetValue(Int32.Parse(arr[i].ToString()), i);
}
but seems like it doesn't work i get error in converting the string into unsigned int32 on the first beginning
an help would be appreciated
© Stack Overflow or respective owner